package cn.elricyu.tt.bean.battle;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import cn.elricyu.tt.bean.FunctionBean;
import cn.elricyu.tt.bean.battle.multi.Team;

public class MyBattle extends FunctionBean {
	public static final int STATUS_READY = 0;
	public static final int STATUS_IN_TEAM = 1;
	private Battle army;
	private int maxnum;
	private int currentnum;
	private Map<String, Team> teamMap = new LinkedHashMap<String, Team>();
	private Map<String, Member> memberMap = new LinkedHashMap<String, Member>();

	public Battle getArmy() {
		return army;
	}

	public void setArmy(Battle army) {
		this.army = army;
	}

	public int getMaxnum() {
		return maxnum;
	}

	public void setMaxnum(int maxnum) {
		this.maxnum = maxnum;
	}

	public int getCurrentnum() {
		return currentnum;
	}

	public void setCurrentnum(int currentnum) {
		this.currentnum = currentnum;
	}

	public Map<String, Team> getTeamMap() {
		return teamMap;
	}

	public void addTeam(Team team) {
		String key = team.getTeamid();
		if (!teamMap.containsKey(key)) {
			teamMap.put(key, team);
		}
	}

	public Map<String, Member> getMemberMap() {
		return memberMap;
	}

	public Member getMember(String key) {
		return memberMap.get(key);
	}

	public void addMember(Member member) {
		String key = member.getPlayerid();
		if (!memberMap.containsKey(key)) {
			memberMap.put(key, member);
		}
	}

	public List<Team> getTeamList() {
		List<Team> teamList = new ArrayList<Team>();
		teamList.addAll(teamMap.values());
		return teamList;
	}

	public List<Member> getMemberList() {
		List<Member> memberList = new ArrayList<Member>();
		memberList.addAll(memberMap.values());
		return memberList;
	}

	public int getStatus() {
		if (!memberMap.isEmpty()) {
			return STATUS_IN_TEAM;
		}
		return STATUS_READY;
	}
}
